import React, {Component} from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'

import memoryUtills from '../utils/memoryUtils'
import zhCN from 'antd/es/locale/zh_CN';
import { Layout, Card, ConfigProvider } from 'antd'
import MainNavbar from '../components/main-navbar/main-navbar'
import MainTime from '../components/mian-time/main-time'
import MainNavbarSide from '../components/main-navbar-side/main-navbar-sider'

import Logo from '../assets/imgs/logo.png'

import Home from './home/home'
import User from './user/user'
import Dict from './sys/dict/dict'
import Menu from './sys/menu/menu'

import './admin.less'

const { Header, Footer, Content } = Layout;

class Admin extends Component{
    render() {
        const user = memoryUtills.user
        if(!user){
            return <Redirect to='/login' />
        }
        return(
            <Layout style={{height:'100%'}}>
                <Header className="main-header">
                    <div className="main-header-sider-left">
                        <img src={Logo} alt={Logo}/>
                        <a href="www.baidu.com">电子药检平台</a>
                    </div>
                    <MainNavbar/>
                    <MainNavbarSide/>
                </Header>
                <Content>
                    <ConfigProvider locale={zhCN}>
                        <Card style={{ width: '96% ',margin: '60px auto',minHeight:'80%'}}>
                            <Switch>
                                <Route path="/home" component={Home}/>
                                <Route path="/user" component={User}/>
                                <Route path="/dict" component={Dict}/>
                                <Route path="/menu" component={Menu}/>
                                <Redirect to="/home"/>
                            </Switch>
                        </Card>
                    </ConfigProvider>
                </Content>
                <Footer>
                    <MainTime/>
                </Footer>
            </Layout>
        )
    }
}

export default Admin